<?php 
session_start();

include("../../conexion.php");
	require_once("../../includes/barramenu.php") ;
	require_once("../../includes/gridView.php")  ;
	require_once("../../includes/combo.php")  	  ;
	$oBarra = new BarraMenu() 				  ;
	$Grid1 = new GridView()					  ;
	$oCombo = new CmbList()  				  ;	
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Permisos de Usuario</title>
<link href="../../includes/css/jquery-ui-notarios.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" href="../../tcal.css" />
<link href="../../includes/css/jquery-ui-notarios.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" href="../../includes/css/uniform.default.min.css" />
<link rel="stylesheet" type="text/css" href="../../tcal.css" />
<script type="text/javascript" src="../../tcal.js"></script> 
<script type="text/javascript" src="../includes/ext_script1.js"></script> 
<script src="../../includes/jquery-1.8.3.js"></script>
<script src="../../includes/js/jquery-ui-notarios.js"></script>
<script src="../../includes/jquery.uniform.min.js"></script>
<script type="text/javascript" src="../../tcal.js"></script> 

<style type="text/css">
div.carta_content {
	background:#333333;
	border: 1px solid #333333;
	-moz-border-radius: 10px;
	-webkit-border-radius: 10px;
	border-radius: 10px;
	-moz-box-shadow: 0px 0px 7px #000000;
	-webkit-box-shadow: 0px 0px 7px #000000;
	box-shadow: 0px 0px 7px #000000;
	width:638px;
	height:220px;
	position:absolute;
	left: 549px;
	top: 496px;
	margin-top: 15px;
	margin-left: -450px;
	opacity: 0.95;
	filter: "alpha(opacity=50)"; /* expected to work in IE 8 */
	filter: alpha(opacity=50);   /* IE 4-7 */
	zoom: 1;
}

div.allcontrata {width:600px; height:150px; overflow:auto;}
.titupatrimo {font-size: 12; font-style: italic; font-family: Calibri;}

div.div_bloques
{ 
background-color: #ffffff;
border: 4px solid #264965;  
-moz-border-radius: 13px;
-webkit-border-radius: 13px;
border-radius: 13px;
-moz-box-shadow: 0px 0px 5px #000000;
-webkit-box-shadow: 0px 0px 5px #000000;
box-shadow: 0px 0px 5px #000000;
width:820px; height:750px;
}

.camposss {font-family: Calibri; font-style: italic; font-size: 14px; color: #333333; }


#cabecera{
	margin:0 auto;
	border: 2px solid #ddd; 
	border-radius: 10px; 
	padding: 2px; 
	box-shadow: #ccc 5px 0 5px;
	margin-bottom:0px;
	}
	
.GridPar
{
	border:0px;
	border-spacing:0px;
	border-collapse:0px;
	font:Arial, Helvetica, sans-serif;
	font-size:11px;
	color:#300;
	cursor:pointer;
	background-color:#FFFFFF;
}
.GridImp
{
	border:0px;
	border-spacing:0px;
	border-collapse:0px;
	font:Arial, Helvetica, sans-serif;
	font-size:11px;
	color:#300;
	cursor:pointer;
	background-color:#E8E8E8;
}
.GridCab
{
	font-size:17px;
	
	
}
<!-- end table -->	
</style>
<script type="text/javascript">

$(document).ready(function(){ 

		 $("button").button();
		 $("#dialog").dialog();
		fmuestraGrid();
	})


	function muesdatos(){ muestragrid(); }

	function fGraba()
	{
		var _id_usuario = document.getElementById('id_uduario');
		if(_id_usuario.value==""){alert('Debe seleccionar un usuario');return;}
		
		else 
		{
			$( "#muesguarda" ).dialog({
				resizable: false,
				height:140,
				position :["center","top"],
				modal: true,
				buttons: {
					"Aceptar": function() { fevalguarda();
					},
					"Cancelar": function() {
						$( this ).dialog( "close" );
					}
				}
			});
		}	
		
	}

	function fevalguarda()
	{ 
		  fguardaPermiUsuario();
		  $("#muesguarda").dialog("close");
	}
	
function fShowDetail(obj)
		{
			var _id = obj.cells[0].innerHTML;
			var _gridView = document.getElementById('gridPedidos');
			var _rows  = _gridView.rows.length;
			for(i=1;i<=_rows-1;i++)
				{
					if(i%2==0)
						{
							_gridView.rows[i].style.backgroundColor = '#FFFFFF';
						}
					else
						{
							_gridView.rows[i].style.backgroundColor = '#E8E8E8';
						}
				}

			obj.style.backgroundColor = '#b4b4b4'; 
			
			var fil=obj.id;
			document.getElementById('txtfilas').value=fil;
			document.getElementById('chktodos').checked = false;
				document.getElementById('chk_protocolares').checked = false;
				document.getElementById('chk_extraproto').checked = false;
				document.getElementById('chk_reportes').checked = false;
				document.getElementById('chk_caja').checked = false;
				document.getElementById('chk_usuarios').checked = false;
				document.getElementById('chk_herramientas').checked = false;
			    document.getElementById('chk_config').checked = false;

			    _datos =  $GridData(obj);
				document.getElementById('id_uduario').value = _datos[0];
				var _idusuario = _datos[0];
				
				var arraydatos = fShowAjaxDato('../model/ProcesaPermi.php?idusuario='+_idusuario);
				
				
				var _busquedaarray = arraydatos;

				var _proto   = "1";
				var _eproto  = "2";
				var _rep     = "3";
				var _caja    = "4";
				var _usuarios= "5";
				var _herramientas = "6";
				var _config  = "7";
				
				for(i=0;i< _busquedaarray.length;i++) {
					if(_proto == _busquedaarray[i]  ){
						document.getElementById('chk_protocolares').checked = true;
					} 
					
				}
				
				for(i=0;i< _busquedaarray.length;i++) {
					if(_eproto == _busquedaarray[i]  ){
						
						document.getElementById('chk_extraproto').checked = true;
					}	
				}
				for(i=0;i< _busquedaarray.length;i++) {
					if(_rep == _busquedaarray[i]  ){
						
						document.getElementById('chk_reportes').checked = true;
					}
				}
				
				for(i=0;i< _busquedaarray.length;i++) {
					if(_caja == _busquedaarray[i]  ){
						
						document.getElementById('chk_caja').checked = true;
					}
				}
				
				for(i=0;i< _busquedaarray.length;i++) {
					if(_usuarios == _busquedaarray[i]  ){
						
						document.getElementById('chk_usuarios').checked = true;
					}
				}
				
				for(i=0;i< _busquedaarray.length;i++) {
					if(_herramientas == _busquedaarray[i]  ){
						
						document.getElementById('chk_herramientas').checked = true;
					}
				}
				
				for(i=0;i< _busquedaarray.length;i++) {
					if(_config == _busquedaarray[i]  ){
						
						document.getElementById('chk_config').checked = true;
					}	
				}
	
				document.getElementById('txt_datospermi').value = arraydatos;
				var _datos = document.getElementById('txt_datospermi').value;
		}




	function fBusUsuario() { fbuscaUsuario();	}

	function frefresh() { window.location.reload(); }

	function fbusca(_val)
	{
		var _seg="seg";
		$("#divUsuariosP").load('list_permisos.php' ,{val       : _val,	_epublic  : _seg });
	}	

	function fmuestraGrid()
	{
		var _ini="ini";
		$("#divUsuariosP").load('list_permisos.php', {_epublic  : _ini});
	}	

	function fadd(_ob)
	{
		if(_ob==true)
		{
			var _num = parseInt(document.getElementById('numcampos').value);
			document.getElementById('numcampos').value = _num + 1;
		}
		if(_ob==false)
		{
			var _num = parseInt(document.getElementById('numcampos').value);
			document.getElementById('numcampos').value = _num - 1;
		}	
		
	}
	
	function fadd1(_ob)
	{
		if(_ob==true)
		{
				document.getElementById('chk_protocolares').checked = true;
				document.getElementById('chk_extraproto').checked = true;
				document.getElementById('chk_reportes').checked = true;
				document.getElementById('chk_caja').checked = true;
				document.getElementById('chk_usuarios').checked = true;
				document.getElementById('chk_herramientas').checked = true;
				document.getElementById('chk_config').checked = true;
		}
		if(_ob==false)
		{
				document.getElementById('chk_protocolares').checked = false;
				document.getElementById('chk_extraproto').checked = false;
				document.getElementById('chk_reportes').checked = false;
				document.getElementById('chk_caja').checked = false;
				document.getElementById('chk_usuarios').checked = false;
				document.getElementById('chk_herramientas').checked = false;
				document.getElementById('chk_config').checked = false;
		}	
		
	}
</script>
</head>

<body style="font-size:62.5%;">
<form id="PermisoxUsu" action="PermisoxUsu.php" method="post" >
<div id="permisos_viaje">
<table align="center" width="90%" border="0" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
  <tr>
    <td>
    <fieldset id="cabecera">
    <legend></legend>
    <table  width="100%">
        <tr>
          <td colspan="5"><table  width="100%">
            <tr>
            
              <td colspan="4"><div id="muesguarda" title="Confirmacion" style="display:none">Desea guardar los permisos..?</div><div id="confirmaGuarda"></div></td>

            </tr>
            <tr>
              <td width="14%"><span class="camposss">Busqueda:</span></td>
              <td width="17%" align="right"><span class="camposss">Nombre del Usuario:</span></td>
              <td width="24%"><input name="busqueda_usuario" type="text" id="busqueda_usuario" style="text-transform:uppercase" size="50" onKeyUp="fbusca(this.value);"/></td>
              <td width="45%" align="left"><a href="#" onClick="fbusca(this.value);"> <img src="../../images/search.png" width="15" height="15" alt="" /></a></td>
              </tr>
          </table></td> 
          </tr>
        <tr>
          <td colspan="2" align="right"><span class="camposss">
            <input name="id_uduario" type="hidden" id="id_uduario" /><input name="numcampos" type="hidden" id="numcampos" value="0" />
          </span></td>
          <td width="32%"><input type="hidden" id="txtfilas" name="txtfilas" value="" />
          <input type="hidden" id="txt_datospermi" name="txt_datospermi" value="" />
          
          </td>
          <td width="57%" colspan="2" rowspan="9" valign="top"><div id="divUsuariosP" class=""></div></td>
          </tr>
        <tr>
          <td width="6%"><input onClick="fadd(this.checked);" type="checkbox" name="chk_protocolares" id="chk_protocolares">
            <label for="d"></label></td>
          <td colspan="2"><span class="camposss">Protocolares</span></td>
          </tr>
        <tr>
          <td><input onClick="fadd(this.checked);" type="checkbox" name="chk_extraproto" id="chk_extraproto">
            <label for="d2"></label></td>
          <td colspan="2"><span class="camposss">Extraprotocolares</span></td>
          </tr>
        <tr>
          <td><input onClick="fadd(this.checked);" type="checkbox" name="chk_reportes" id="chk_reportes">
            <label for="d3"></label></td>
          <td colspan="2"><span class="camposss">Reportes</span></td>
          </tr>
        <tr>
          <td><input onClick="fadd(this.checked);" type="checkbox" name="chk_caja" id="chk_caja">
            <label for="d4"></label></td>
          <td colspan="2"><span class="camposss">Caja</span></td>
        </tr>
        <tr>
          <td><input onClick="fadd(this.checked);" type="checkbox" name="chk_usuarios" id="chk_usuarios">
            <label for="d5"></label></td>
          <td colspan="2"><span class="camposss">Usuarios</span></td>
        </tr>
        <tr>
          <td><input onClick="fadd(this.checked);" type="checkbox" name="chk_herramientas" id="chk_herramientas">
            <label for="d6"></label></td>
          <td colspan="2"><span class="camposss">Herramientas</span></td>
        </tr>
        <tr>
          <td><input onClick="fadd(this.checked);" type="checkbox" name="chk_config" id="chk_config">
            <label for="d7"></label></td>
          <td colspan="2"><span class="camposss">Configuracion</span></td>
        </tr>
          <tr>
          <td><input onClick="fadd1(this.checked);" type="checkbox" name="chktodos" id="chktodos">
            <label for="d7"></label></td>
          <td colspan="2"><span class="camposss">Seleccionar Todos</span></td>
        </tr>
        <tr>
          <td colspan="3" align="center">
            <button title="Contratantes" type="button" name="btncontratantes"    id="btncontratantes" value="contratantes" onclick="fGraba();" ><img src="../../images/newuser.png" width="20" height="20" align="absmiddle" />Grabar Permisos</button>
          </td>
          </tr>
        </table>
    </fieldset>  
      </td>
    </tr>
  <tr>
    <td height="30" >
   <!--<input name="id_viaje" type="hidden" id="id_viaje" /> --></td>
  </tr>
</table>

</div>
<script language="javascript">
	$(document).ready(function(){
		$('#gridImpedidos').scrollableFixedHeaderTable(700,620,null,null)
			
		});  
</script>
</form>
</body>
</html>